<!--课时量查询-->
<template>
  <div class="assessment-container">
     <div class="search-container" style="padding-left:0">
      <div class="search-container-left">
        <div class="search-container-item">
          <span>学期：</span>
          <el-select
            v-model="xq"
            style="width: 90px"
            size="mini"
            clearable
            placeholder="请选择学期"
          >
            <el-option
              v-for="(item, index) in xqList"
              :key="index"
              :label="item.name"
              :value="item.id"
            >
            </el-option>
          </el-select>
        </div>
      <div v-if="roleId !== '1490880469703041025' && roleId !== '1475294432243830786'" class="search-container-item">
          <span>教学系:</span>
          <el-select
            v-model="classroom"
            style="width: 114px"
            size="mini"
            placeholder="请选择教学系"
            clearable
            @change="handleChangeJxx"
          >
            <el-option
              v-for="item in classroomList"
              :key="item.value"
              :label="item.value"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </div>
        <div v-if="roleId !== '1475294432243830786'" class="search-container-item">
          <span>教研室:</span>
          <el-select
            v-model="research"
            style="width: 124px"
            size="mini"
            clearable
            placeholder="请选择教研室"
          >
            <el-option
              v-for="item in researchList"
              :key="item.id"
              :label="item.value"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </div>
        <div v-if="roleId !== '1475294432243830786'" class="search-container-item">
          <span>授课教员:</span>
          <el-input
            style="width: 152px"
            size="mini"
            clearable
            placeholder="请输入授课教员"
            v-model="skjy"
          ></el-input>
        </div>
        <div v-if="roleId !== '1475294432243830786'" class="search-container-item">
          <span>课程名称：</span>
          <el-input
            style="width: 152px"
            size="mini"
            clearable
            placeholder="请输入课程名称"
            v-model="coursename"
          ></el-input>
        </div>
         <div class="search-button">
          <img src="../../../assets/assessment/icon-search.png" alt="" />
          <span @click="updatePostList">查询</span>
        </div>
         <div class="search-buttons" style="width:95px;background: #FEF1E8; border-color:#F86900;">
          <!-- <img src="../../../assets/assessment/icon-search.png" alt="" /> -->
          <span @click="toManualEntry(xq)" style="color:#F86900">查看统计</span>
        </div>
        <div class="search-buttons" style="width:95px;background: #EFEBFF; border-color:#5230E9;">
          <span @click="pltx()" style="color:#5230E9">批量提醒</span>
        </div>
      </div>
    </div>
    <div class="plan-entry-table-container table-container">
      <el-table
        :data="tableData"
        border
        style="width: 100%"
        class="table-data"
        row-class-name="row-class"
        cell-class-name="cell-class"
        header-row-class-name="header-row-class"
        header-cell-class-name="header-cell-class"
      >
        <el-table-column prop="semesterName" label="学期" width="70" align="center">
        </el-table-column>
        <el-table-column prop="teacherName" label="教员" width="70" align="center">
        </el-table-column>
        <el-table-column prop="df" label="教学系" width="70" align="center">
        </el-table-column>
        <el-table-column prop="department" label="教研室" width="80" align="center">
        </el-table-column>
        <el-table-column prop="rank" label="职称" width="61" align="center">
        </el-table-column>
        <el-table-column
          prop="jobGrade"
          label="高/中/初职"
          width="88"
          align="center"
        >
        </el-table-column>
        <el-table-column
          prop="goodLesson"
          label="是否优质课"
          width="61"
          align="center"
        >
        </el-table-column>
        <el-table-column
          prop="courseName"
          label="课程名称"
          width="101"
          align="center"
        >
        </el-table-column>
        <el-table-column prop="teachNature" label="课程性质" width="61" align="center">
        </el-table-column>
        <el-table-column prop="task" label="承担任务" width="90" align="center">
        </el-table-column>
        <el-table-column prop="actual" label="实装/实弹" width="99" align="center">
        </el-table-column>
        <el-table-column
          prop="equipment"
          label="装备名称/型号"
          width="103"
          align="center"
        >
        </el-table-column>
        <el-table-column prop="teachObject" label="教学对象" width="77" align="center">
        </el-table-column>
        <el-table-column
          prop="className"
          label="教学班名称"
          width="79"
          align="center"
        >
        </el-table-column>
        <el-table-column
          prop="studentNumber"
          label="实际上课人数"
          align="center"
          width="76"
        >
        </el-table-column>
        <el-table-column
          prop="jshour"
          label="实际理论讲授课时"
          align="center"
          width="76"
        >
        </el-table-column>
        <el-table-column
          prop="sjhour"
          label="实际实践讲授课时"
          align="center"
          width="76"
        >
        </el-table-column>
        <el-table-column
          prop="conuthour"
          label="实际合计课时"
          align="center"
          width="76"
        >
        </el-table-column>
        <el-table-column
          prop="acc"
          label="课时折算系数"
          align="center"
          width="76"
        >
        </el-table-column>
        <el-table-column prop="workload" label="课时量" align="center" width="61">
        </el-table-column>
        <el-table-column prop="classStandard" label="课时标准" align="center" width="81">
        </el-table-column>
        <el-table-column
          prop="addHours"
          label="优质课增发课时"
          align="center"
          width="61"
        >
        </el-table-column>
        <el-table-column
          prop="addStandard"
          label="优质课增发标准"
          align="center"
          width="101"
        >
        </el-table-column>
        <el-table-column prop="commonts" label="备注" align="center">
        </el-table-column>
      </el-table>
    </div>
    <div class="bottom-block-export">
      <img src="../../../assets/workload/icon-yellow-export.png" alt="" />
      <download-excel
        class="export-btn"
        :data="tableData"
        :fields="jsonFields"
        type="xls"
        name="课时量信息.xls"
        style="color: #f3b815"
      >
        &ensp;导出Excel
      </download-excel>
    </div>
  </div>
</template>

<script>
import {queryPostList, getJxx, getJys, getXq, getJysByJxx} from "../../../api/classHoursAddList/ClassTimeQuery";
import {queryCommonXueqi, queryDefaultXueQi, course_time_tx} from "@/api/trainingManagement/place.js"
import { getStore } from "@/util/store.js"
export default {
  data() {
    return {
      skjy:"",
      coursename:"",
      xq: "",
      xqList: [],
      research: "",
      researchList: [],
      classroom: "",
      classroomList: [],
      tableData: [],
      roleId: '',
      jsonFields:{
        '学期': 'semester',
        '教员': 'teacherName',
        '教学系系': 'df',
        '教研室': 'department',
        '职称': 'rank',
        '高/中/初职': 'jobGrade',
        '是否优质课': 'goodLesson',
        '课程名称': 'courseName',
        '课程性质': 'teachNature',
        '承担任务': 'task',
        '实装/实弹': 'actual',
        '装备名称/型号': 'equipment',
        '教学对象': 'teachObject',
        '教学班名称': 'className',
        '实际上课人数': 'studentNumber',
        '实际理论讲授课时': 'jshour',
        '实际实践讲授课时': 'sjhour',
        '实际合计课时': 'conuthour',
        '课时折算系数': 'acc',
        '课时量': 'workload',
        '课时标准': 'classStandard',
        '优质课增发课时': 'addHours',
        '优质课增发标准': 'addStandard',
        '备注': 'commonts',
      },
    };
  },
  created() {
    const userInfo = getStore({
      name: "userInfo",
      debug: true,
    }) || {}
    this.roleId = userInfo.content.role_id
  },
  methods: {
     getJxx: function () {
        return new Promise(() => {
          getJxx().then(res => {
            this.classroomList = res.data.data;
          })
        })
    },
    getJys: function () {
        return new Promise(() => {
          getJys().then(res => {
            console.log(res.data.data, '1111111111111111')
            this.researchList = res.data.data
          })
        })
    },
    toManualEntry(xq) {
       this.$router.push({path:"/admin/ManagementHours/viewStatistics",query:{xq:xq}});
    },
    addHours() {
      this.$router.push("/teacher/workload/ClassTimeQuery");
    },
     queryPostList: function () {
      let obj = {
        semester: this.xq,
      }
      return new Promise(() => {
        queryPostList(obj).then(res => {
          this.tableData = res.data.data;
        })
      })
    },
     updatePostList: function () {
      let obj = {
        semester: this.xq,
        df:this.classroom,
        department:this.research,
        teacherName:this.skjy,
        courseName: this.coursename
      }
      return new Promise(() => {
        queryPostList(obj).then(res => {
          this.tableData = res.data.data;

        })
      })
    },
    handleInitXq: function () {
      return new Promise(() => {
        queryCommonXueqi().then(res => {
          this.xqList = res.data.data
        })
      })
    },
    handleChangeJxx: function (val) {
      return new Promise(() => {
        if (val === '') {
          this.getJys()
        } else {
          getJysByJxx(val).then(res => {
            this.researchList = res.data.data
          })
        }
      })
    },
    async getDefaultXueQi(){
      queryDefaultXueQi().then(res=>{
        if(res.data.code == 200){
          this.xq = res.data.data
        }
      }).then(()=>{
        this.queryPostList()
      })
    },
    pltx(){
      if(this.tableData && this.tableData.length > 0){
        let tempArray = []
        this.tableData.forEach(item=>{
          // tempArray.push({
          //   teacherIds: item.teacherId
          // })
          tempArray.push(item.teacherId)
        })
        let data = {teacherIds: tempArray}
        course_time_tx(data).then(res=>{
          if(res.data.code == 200){
            this.$message.success('批量提醒成功')
          }
        })
      }
    },
  },
  mounted(){
    this.getDefaultXueQi()
    // this.queryPostList();
    this.handleInitXq()
    this.getJxx();
    this.getJys();
  },

};
</script>
<style lang="less" scoped>
.plan-entry-table-container {
  margin-top: 30px;
  .el-table td,
  .el-table th.is-leaf,
  .el-table--border,
  .el-table--group {
    border-color: #c7d7eb;
  }
  .el-table__header tr,
  .el-table__header th {
    padding: 0;
    height: 82px;
    background-color: #edf2f9;
    font-size: 16px;
    font-family: Microsoft YaHei;
    font-weight: bold;
    line-height: 20px;
    color: #004ca7;
  }

  .el-table__body tr,
  .el-table__body td {
    padding: 0;
    height: 86px;
  }
  .el-table th.el-table__cell > .cell {
    padding: 0;
  }
  .el-table .cell,
  .el-table--border .el-table__cell:first-child .cell {
    padding: 0;
  }
  .el-table__body td .cell {
    padding: 0;
  }

  .add-button {
    margin: 0 auto;
    cursor: pointer;
    background: #fff6ef;
    border: 1px solid #f3b815;
    width: 65px;
    height: 28px;
    line-height: 28px;
    border-radius: 6px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    > span {
      font-size: 14px;
      font-family: Microsoft YaHei;
      font-weight: 400;
      color: #f3b815;
    }
    > img {
      width: 13px;
      height: 13px;
      margin-right: 8px;
    }
  }
  .pass-text {
    font-size: 14px;
    font-family: Microsoft YaHei;
    font-weight: 400;
    color: #51aef6;
  }
  .wait-text {
    font-size: 14px;
    font-family: Microsoft YaHei;
    font-weight: 400;
    color: #ff3819;
  }
  .watch-button {
    width: 76px;
    height: 36px;
    background: #fef1e8;
    border: 1px solid #f86900;
    border-radius: 6px;
    font-size: 14px;
    font-family: Microsoft YaHei;
    font-weight: 400;
    color: #f86900;
    line-height: 16px;
    margin: 2px auto;
  }
}
</style>

<style lang="less" scoped>
.assessment-container {
  /*width: 1875px;*/
  /*margin: 0 auto;*/
  .search-container {
    margin-top: 27px;
    padding-left: 43px;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    .search-container-left,
    .search-container-right {
      display: flex;
      flex-direction: row;
    }
    .search-container-item {
      color: #004ca7;
      font-size: 16px;
      font-family: Microsoft YaHei;
      font-weight: 400;
      margin-right: 30px;
      > span {
        margin-right: 6px;
      }
    }
    .search-button {
      width: 77px;
      height: 28px;
      line-height: 28px;
      background: #f1f8fe;
      border: 1px solid #51aef6;
      border-radius: 6px;
      cursor: pointer;
      display: flex;
      flex-direction: row;
      align-items: center;
      justify-content: center;
      > span {
        font-size: 16px;
        font-family: Microsoft YaHei;
        font-weight: 400;
        color: #51aef6;
      }
      > img {
        width: 20px;
        height: 20px;
        margin-right: 4px;
      }
    }
     .search-buttons {
      width: 107px;
      height: 28px;
      line-height: 28px;
      background: #f1f8fe;
      border: 1px solid #51aef6;
      border-radius: 6px;
      cursor: pointer;
      display: flex;
      flex-direction: row;
      align-items: center;
      justify-content: center;
      margin-left: 10px;
      > span {
        font-size: 16px;
        font-family: Microsoft YaHei;
        font-weight: 400;
        color: #51aef6;
      }
      > img {
        width: 20px;
        height: 20px;
        margin-right: 4px;
      }
    }
  }
  .bottom-block-export {
    right: 0;
    width: 127px;
    height: 27px;
    line-height: 34px;
    background: #fff6ef;
    border: 1px solid #f3b815;
    opacity: 1;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    margin-top: 10px;
    > span {
      font-size: 16px;
      font-family: Source Han Sans CN;
      font-weight: 500;
      color: #f3b815;
    }
    > img {
      width: 16px;
      height: 16px;
      margin-right: 9px;
    }
  }
  .plan-entry-table-container {
    margin-top: 30px;
    .table-data {
      width: 100%;
      border: 0.8px solid #004ca7;
      border-radius: 9px;
      font-size: 14px;
      font-family: Microsoft YaHei;
      font-weight: 400;
      color: #004ca7;
    }
  }
}

/deep/ .table-container {
  .el-table td,
  .el-table th.is-leaf,
  .el-table--border,
  .el-table--group {
    border-color: #c7d7eb;
  }

  .el-table__header tr,
  .el-table__header th {
    padding: 0;
    height: 76px;
    background-color: #edf2f9;
    font-size: 16px;
    font-family: Microsoft YaHei;
    font-weight: bold;
    line-height: 20px;
    color: #004ca7;
  }

  .el-table__body tr,
  .el-table__body td {
    padding: 0;
    height: 86px;
  }
}
</style>
